package Demo;


abstract class Animal {
    public Animal(String name) {
        this.name = name;
    }

    public Animal() {
    }
    public static void animalEat(Animal animal) {
        animal.eat();
    }
    String name;
    public abstract void eat();
}

class Dog extends Animal{
    public Dog() {
    }

    public Dog(String name) {
        super(name);
    }
    public void eat() {
        System.out.println(this.name + "吃狗粮");
    }
}

class Cat extends Animal {
    public Cat() {
    }

    public Cat(String name) {
        super(name);
    }
    public void eat() {
        System.out.println(this.name + "吃猫粮");
    }
}

public class Test {
    public static void main(String[] args) {
        Animal animal1 = new Dog("豆豆");
        Animal animal2 = new Cat("花花");
        Animal.animalEat(animal1);
        Animal.animalEat(animal2);
    }
}


